﻿using IBLL;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Model;

namespace Week3.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class RoomNumController : ControllerBase
    {
        public RoomNumController(IRoomNunBLL bLL)
        {
            BLL = bLL;
        }

        public IRoomNunBLL BLL { get; }
        /// <summary>
        /// 查全部信息
        /// </summary>
        /// <returns>返回</returns>
        [HttpGet]
        public IQueryable<RoomNum> GetAll()
        {
            return BLL.GetAll();
        }
        /// <summary>
        /// 批量修改状态
        /// </summary>
        /// <param name="id">编号</param>
        /// <param name="state">状态</param>
        /// <returns>返回</returns>
        [HttpGet]
        public Task<int> UpdateAllState(int id, bool state) 
        {
            return BLL.UpdateAllState(id, state);  
        }

        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="t">参数</param>
        /// <returns>返回</returns>
        [HttpPut]
        public Task<int> UpdateAsync(RoomNum t)
        {
            return BLL.UpdateAsync(t);
        }

        /// <summary>
        /// 根据编号查一条数据
        /// </summary>
        /// <param name="id">编号</param>
        /// <returns>返回</returns>
        [HttpGet]
        public RoomNum GetValue(int id) 
        {
            return BLL.GetValue(id);
        }
    }
}
